<template>
  <div>
    <el-cascader
      v-model="bloc.value"
      :options="bloc.options"
      :placeholder="'           请选择'"
      style="width:100%;"
      :props="{multiple:true}"
      @change="handleChange">
      <template slot-scope="{ node, data }">
        <span :title="data.FaultDescription">
          {{ node.label }}
        </span>
      </template>
    </el-cascader>
  </div>
</template>

<script lang='ts'>
    // import { getLabelList } from './api.js'
    import { Component, Prop, Vue } from 'vue-property-decorator';
    import {FaultSelectorBloc} from '@/component/bloc/FaultSelectorBloc';

    @Component
    export default class UserSelector extends Vue {
        @Prop({ type: Number })
        readonly PId! : number;

        bloc = new FaultSelectorBloc();
        async created () {
            await this.bloc.load();
            if (this.PId) {
                await this.bloc.getFault(this.PId);
            }
            let address = this.bloc.normalizedOptions;
            address.forEach(item => {
                this.bloc.options.push(item)
            })
        }

        handleChange(value) {
          // console.log(value);
          this.$emit('change', value, this.bloc.normalizedOptions)
        }
    }
</script>

<style lang='less' scoped>
  /deep/ .el-cascader__tags {
    padding-left: 3em;
  }
</style>
